package algorithms.que13;

import java.util.Stack;

/**
 * @功能
 * @创建时间 2020/7/7
 */
public class CopyStack {
    public static void main(String[] args) {
        Stack<String> a = new Stack<>();
        for(int i=0;i<10;i++){
            a.push(String.valueOf(i));
        }
       Stack<String> b= copy(a);
        int bsize=b.size();
        for(int i=0;i<bsize;i++){
            System.out.println(b.pop());
        }
    }
    public static Stack<String> copy(Stack<String> a){
        Stack b = new Stack();
        Stack<String> c = new Stack<>();
        int size = a.size();
        for(int i=0;i<size;i++){
            c.push(a.pop());
        }
        int csize = c.size();
        for(int i=0;i<csize;i++){
            String s=c.pop();
            b.push(s);
            a.push(s);
        }
        return b;
    }
}
